package org.zjt.agent.bytebuddy.binder;

import net.bytebuddy.implementation.bind.annotation.*;
import net.bytebuddy.utility.JavaConstant;
import org.zjt.agent.generate.bytebuddy.OverrideCallable;
import org.zjt.agent.generate.bytebuddy.OverrideConsumer;

import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
import java.util.function.Consumer;

/**
 * @author <a href="juntao.zhang@bkjk.com">juntao.zhang</a>
 * @Description:
 * @Package org.zjt.agent.bytebuddy.binder
 * @date 2018/2/27 15:34
 * @see
 */
public class ToStringInterceptor {

    @RuntimeType
    public static Object callableIntercepte(@This Object obj,
                                    @Morph OverrideCallable overrideCallable ,
                                    @AllArguments Object[] allArguments,
                                    @Origin Method method) {

        System.err.println("------------makeString------------------");
        Object call = overrideCallable.call(allArguments);
        return call;
    }


    @RuntimeType
    public static void consumeIntercepte(@This Object obj,
                                            @Morph OverrideConsumer overrideConsumer ,
                                            @AllArguments Object[] allArguments,
                                            @Origin Method method) {

        System.err.println("------------makeString------------------");
        overrideConsumer.call(allArguments);

    }







    public static String makeString2(@StringValue String value) {


        System.err.println("makeString 2 " +value );

        return value;
    }

}
